package org.bot.server.job;

import org.bot.server.flow.service.BotFlowService;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: 沧月
 * @Date: 2023/12/9 11:27
 * @Description: 描述
 */
@Component
public class FlowJob implements Job {

    private static BotFlowService BOT_FLOW_SERVICE;

    @Autowired
    public void setBotFlowService(BotFlowService botFlowService) {
        BOT_FLOW_SERVICE = botFlowService;
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) {
        JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap();
        Object id = jobDataMap.get("flowId");
        BOT_FLOW_SERVICE.executeFlow(Integer.parseInt(id.toString()));
    }
}
